<?php
namespace voxfa\log;
require_once dirname(__FILE__)."/../../lib/log4php/Logger.php";

class LogFactory {
	
	/* Factory methods */ 
	
	/**
	 * Get a Logger by name (Delegate to {@link Logger})
	 * 
	 * @param string $name logger name
	 * @param LoggerFactory $factory a {@link LoggerFactory} instance or null
	 * @return Logger
	 * @static 
	 */
	public static function getLogger($name) {
		return \Logger::getLogger($name);
	}
	
	/**
	 * get the Root Logger (Delegate to {@link Logger})
	 * @return LoggerRoot
	 * @static 
	 */	   
	public static function getRootLogger() {
		return \Logger::getHierarchy()->getRootLogger();	  
	}
	
	/**
	 * Clears all logger definitions
	 * 
	 * @static
	 * @return boolean 
	 */
	public static function clear() {
		return \Logger::getHierarchy()->clear();	 
	}
	
	/**
	 * Destroy configurations for logger definitions
	 * 
	 * @static
	 * @return boolean 
	 */
	public static function resetConfiguration() {
		return \Logger::resetConfiguration();	 
	}
	
	/**
	 * check if a given logger exists.
	 * 
	 * @param string $name logger name 
	 * @static
	 * @return boolean
	 */
	public static function exists($name) {
		return \Logger::getHierarchy()->exists($name);
	}
	
	/**
	 * Returns an array this whole Logger instances.
	 * 
	 * @static
	 * @see Logger
	 * @return array
	 */
	public static function getCurrentLoggers() {
		return \Logger::getHierarchy()->getCurrentLoggers();
	}
	
	/**
	 * Configures Log4PHP.
	 * This method needs to be called before the first logging event
	 * has occured. If this methode is never called, the standard configuration
	 * takes place (@see LoggerConfiguratorBasic).
	 * If only the configuration file is given, the configurator class will
	 * be the XML Configurator or the INI Configurator, if no .xml ending
	 * could be determined.
	 * 
	 * If a custom configurator should be used, the configuration file
	 * is either null or the path to file the custom configurator uses.
	 * Make sure the configurator is already or can be loaded by PHP when necessary.
	 * 
	 * @param String $configurationFile the configuration file
	 * @param String $configurationClass the configurator class
	 */
	public static function configure($configurationFile = null, 
									 $configurationClass = null ) {
		\Logger::configure($configurationFile,$configurationClass);
	}
	
	/**
	 * Returns the current configurator
	 * @return the configurator
	 */
	public static function getConfigurationClass() {
		return \Logger::getConfigurationClass();
	}
	
	/**
	 * Returns the current configuration file
	 * @return the configuration file
	 */
	public static function getConfigurationFile() {
		return \Logger::getConfigurationFile();
	}
	
	/**
	 * Returns, true, if the log4php framework is already initialized
	 */
	private static function isInitialized() {
		return \Logger::isInitialized();
	}
	
	/**
	 * Initializes the log4php framework.
	 * @return boolean
	 */
	public static function initialize() {
		return \Logger::initialize();
	}
}